<?php
// No direct access to this file
defined('_JEXEC') or die;
 
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
 
/**
 * HelloWorld Form Field class for the HelloWorld component
 */
class JFormFieldKMS_Video_Label extends JFormFieldList
{
        /**
         * The field type.
         *
         * @var         string
         */
        protected $type = 'KMS_Video_Label';
 
        /**
         * Method to get a list of options for a list input.
         *
         * @return      array           An array of JHtml options.
         */
        protected function getOptions() 
        {
                $db = JFactory::getDBO();
                $query = $db->getQuery(true);
                $query->select('label_id,label_value');
                $query->from('#__kms_labels');
                $db->setQuery((string)$query);
                $videos = $db->loadObjectList();
                $options = array();
                if ($videos)
                {
                        foreach($videos as $video) 
                        {
                                $options[] = JHtml::_('select.option', $video->label_id, $video->label_value);
                        }
                }
                $options = array_merge(parent::getOptions(), $options);
                return $options;
        }
}
